<template>
    <div>
        <el-form :inline="true" :model="params" class="demo-form-inline">
        <el-form-item label="状态">
            <el-select v-model="params.isStart" placeholder="请选择">
            <el-option label="开启" :value="1"></el-option>
            <el-option label="关闭" :value="0"></el-option>
            </el-select>
        </el-form-item>
        <el-form-item>
            <el-button type="primary" @click="onSubmit">查询</el-button>
            <el-button type="primary" @click="createdefense">创建答辩室</el-button>
        </el-form-item>
        </el-form>
        <el-table
      :data="subList"
      style="width: 100%">
      <el-table-column
        prop="id"
        label="编号"
        width="180">
      </el-table-column>
      <el-table-column
        prop="replyName"
        label="答辩室名称"
        width="180">
      </el-table-column>
      <el-table-column
        prop="isStart"
        label="状态">
        <template slot-scope="scope">
             <el-switch
                v-model="scope.row.isStart"
                active-color="#13ce66"
                inactive-color="#ff4949"
                :active-value="1"
                :inactive-value="0"
                @change="udateStart(scope.row)">
            </el-switch>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="params.curPage"
      :page-sizes="[10, 20, 30, 40]"
      :page-size="params.limit"
      layout="total, sizes, prev, pager, next, jumper"
      :total="total">
    </el-pagination>
    <div v-if="open==2">
    </div>
    </div>
</template>

<script>
export default {
    data(){
        return{
            subList:[],
            params:{
                curPage:1,
                limit:10,
                isStart:null
            },
            total:0,
            open:1
        }
    },
    methods:{
        findPage(){
            this.$http({
              url: this.$http.adornUrl(`/reply/replygroup/findAll/${this.params.curPage}/${this.params.limit}`),
              method: 'post',
              data: this.$http.adornData({
                'replyName': this.params.replyName,
                'isStart': this.params.isStart,
              })
            }).then(({data}) => {
              this.subList = data.page.records;
              this.total = data.page.total;
            })
        },
        onSubmit(){
            this.findPage();
        },
        handleSizeChange(val){
            this.params.limit = val;
            this.findPage();
        },
        handleCurrentChange(val){
            this.params.curPage = val;
            this.findPage();
        },
        createdefense(){
            this.$router.push({path:'/reply-createdefense'});
        },
        udateStart(row){
            this.$http({
              url: this.$http.adornUrl(`/reply/replygroup/update/`),
              method: 'post',
              data: this.$http.adornData({
                'id': row.id,   
                'replyName': row.replyName,
                'isStart': row.isStart,
              })
            }).then(({data}) => {
                alert("修改成功")
                this.findPage()
            })
        }
    },
    mounted(){
        this.findPage()
    }
}
</script>

<style>

</style>
